# Importing Data
SWEDEN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Steel/TSA.xlsx",sheet = "Sheet1", range = "AG1:AG239")

# Checking the Imported Data
View(SWEDEN)
# Creating Time Series Data
Sweden_ts <- ts(SWEDEN, start=c(2000,1), end=c(2019,09), frequency=12)
# Viewing and Checking the Created Time Series Data
Sweden_ts
sum(is.na(Sweden_ts))
library(forecast)
Sweden_ts <- tsclean(Sweden_ts)
Sweden_ts

# Identification: Plotting the Time Series Data
plot(Sweden_ts)

# Estimating the appropriate model
Sweden_ts_model <- auto.arima(Sweden_ts)
Sweden_ts_model

# Forecasting
options(max.print=1000000)
Sweden_ts_forecast <- forecast (Sweden_ts_model, level=c(95), h=255)
plot(Sweden_ts_forecast)
Sweden_ts_forecast             

# Exporting
write.table(Sweden_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Steel/SWEDEN_TSA.csv", sep=",")
